if ( SERVER ) then

AddCSLuaFile( "shared.lua" )

SWEP.HoldType = "thrown"

end

if ( CLIENT ) then

SWEP.PrintName = "Wiimote"
SWEP.Author = "Chili Bean"
SWEP.Contact		= ""
SWEP.Purpose = ""
SWEP.Instructions = "Primary:Lightning Seconday:Suicide bomb!"
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.IconLetter = "h"

killicon.AddFont( "weapon_knife", "CSKillIcons", SWEP.IconLetter, Color( 255, 255, 255, 255 ) )

end

SWEP.DrawCrosshair = true
SWEP.DrawAmmo = false

SWEP.Spawnable = false
SWEP.AdminSpawnable = true

SWEP.ViewModel = "models/weapons/v_knife_t.mdl"
SWEP.WorldModel = "models/weapons/w_wii_controller.mdl"

SWEP.Weight = 5
SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = false


SWEP.Primary.Recoil = 0
SWEP.Primary.Damage = 9999
SWEP.Primary.NumShots = 0
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = 1
SWEP.Primary.Delay = 0.01
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"

SWEP.Secondary.Recoil = 0.0
SWEP.Secondary.Damage = 9999
SWEP.Secondary.NumShots = 1
SWEP.Secondary.Cone = 0.0
SWEP.Secondary.ClipSize = 9999
SWEP.Secondary.Delay = 0.0
SWEP.Secondary.DefaultClip = 9998
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"


function SWEP:PrimaryAttack()


if ( !self:CanPrimaryAttack() ) then return end

self.Weapon:EmitSound(Sound("Weapon_AWP.Single"))

self:ShootBullet( 0, 0, 0 )

self:TakePrimaryAmmo( 0 )

self.Owner:ViewPunch( Angle( 0, 0, 0 ) )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.15 )

local trace = self.Owner:GetEyeTrace()
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetNormal( trace.HitNormal )
effectdata:SetEntity( trace.Entity )
effectdata:SetAttachment( trace.PhysicsBone )
util.Effect( "super_explosion", effectdata )

local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetStart( self.Owner:GetShootPos() )
effectdata:SetAttachment( 1 )
effectdata:SetEntity( self.Weapon )
util.Effect( "ToolTracer", effectdata )
if (SERVER) then
local owner=self.Owner
if self.Owner.SENT then
owner=self.Owner.SENT.Entity
end

local explosion = ents.Create( "env_explosion" )
explosion:SetPos(trace.HitPos)
explosion:SetKeyValue( "iMagnitude" , "170" )
explosion:SetPhysicsAttacker(owner)
explosion:SetOwner(owner)
explosion:Spawn()
explosion:Fire("explode","",0)
explosion:Fire("kill","",0 )

end
end

function SWEP:SecondaryAttack()


if ( !self:CanPrimaryAttack() ) then return end

self.Weapon:EmitSound(Sound("none"))

self:ShootBullet( 0, 0, 0 )

self:TakePrimaryAmmo( 0 )

self.Owner:ViewPunch( Angle( 0, 0, 0 ) )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.15 )

local trace = self.Owner:GetEyeTrace()
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetNormal( trace.HitNormal )
effectdata:SetEntity( trace.Entity )
effectdata:SetAttachment( trace.PhysicsBone )
util.Effect( "", effectdata )

local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetStart( self.Owner:GetShootPos() )
effectdata:SetAttachment( 1 )
effectdata:SetEntity( self.Weapon )
util.Effect( "", effectdata )
if (SERVER) then
local owner=self.Owner
if self.Owner.SENT then
owner=self.Owner.SENT.Entity
end

local explosion = ents.Create( "env_explosion" )
explosion:SetPos(trace.HitPos)
explosion:SetKeyValue( "iMagnitude" , "5000" )
explosion:SetPhysicsAttacker(owner)
explosion:SetOwner(owner)
explosion:Spawn()
explosion:Fire("explode","",0)
explosion:Fire("kill","",0 )

end
end

/*---------------------------------------------------------
			Deploy
---------------------------------------------------------*/

function SWEP:Deploy()
if (SERVER) then
self.Owner:SetMaterial("sprites/heatwave")
self.Weapon:SetMaterial("sprites/heatwave")
self.Owner:Fire("addoutput", "rendermode 11", 0)
self.Weapon:Fire("alpha", 0, 0)
self.Owner:Fire("alpha", 0, 0)
self.Weapon:SetKeyValue("renderamt", "0")
self.Owner:SetKeyValue("renderamt", "0")
end
return true
end

/*---------------------------------------------------------
			Holster
---------------------------------------------------------*/

function SWEP:Holster()
if (SERVER) then
self.Owner:SetMaterial("")
self.Weapon:SetMaterial("")
self.Owner:Fire("addoutput", "rendermode 2", 0)
self.Weapon:Fire("alpha", 255, 0)
self.Owner:Fire("alpha", 255, 0)
self.Weapon:SetKeyValue("renderamt", "255")
self.Owner:SetKeyValue("renderamt", "255")
end
return true
end